
<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title></title>
    #include("../../common/res.html")
</head> 
<body class="easyui-layout" data-options="fit:true" style="height:100%;">
    
    <div class="container" data-options="region:'center',border:false" style="height:100%;">
      <table  id="dg" style="width:100%;height:100%;"></table>
      <div id="tb" style="padding:0 30px;">
      	开始：<input  type="text" id="startTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:166px;height:30px;line-height:30px;">
      	结束：<input  type="text" id="endTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:166px;height:30px;line-height:30px;">
      	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="btn_search" data-options="selected:true">查询</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" id="btn_remove">清空</a>
      </div>
    </div>
    <div id="wu-dialog"></div>
    
    <script type="text/javascript">
        $(function(){
            $('#dg').datagrid({
                url:'#(ctx)/admin/log/getData',
                idField:'id',
                method:'get',
                toolbar:"#tb",
                fitColumns:true,
                nowrap:false,
                rownumbers:true,
                singleSelect:true,
                pagination:true,
                striped:true,
                checkOnSelect:false,
                selectOnCheck:false,
                fit:true,
                pageSize:20,
                sortName:'id',
                sortOrder:'desc',
                columns:[[
                    {field:'from',title:'来源',width:400},
                    {field:'ip',title:'IP',width:150},
                    {field:'username',title:'操作用户',width:100},
                    {field:'url',title:'action',width:200},
                    {field:'err_code',title:'状态',width:160,formatter:function(val){if(val==0){return '正常';}else{return '异常'}}},
                    {field:'err_msg',title:'异常信息',width:400},
                    {field:'class_name',title:'类名',width:400},
                    {field:'method_name',title:'方法',width:160},
                    {field:'start_time',title:'记录时间',width:200},
                    {field:'spend_time',title:'执行时间',width:160},
                    {field:'params',title:'参数',width:200}
                ]],
                onLoad:function(){
                    
                },
            }); 
            $("#btn_search").click(function(){
                $('#dg').datagrid('load',{
                    startTime:$("#startTime").val(),
                    endTime:$("#endTime").val()
                });
            });
            $("#btn_remove").click(function(){
                $.messager.confirm('确认对话框', '是否清空日志？', function(r){
                    if (r){
                      $.post("#(ctx)/admin/log/del",{},function(data){
                    	  _toast(data.msg);
                          if(data.code==0){
                        	  reloadGrid();
                          }
                      },'json');
                    }
                });
            });
        });
        function reloadGrid(){
        	$('#dg').datagrid("reload");
        }
        function setVisible(visible){
			var rows=$('#dg').datagrid("getChecked");
            var ids=[];
            for(var i in rows){
                ids.push(rows[i].id);
            }
            if(rows.length==0){
                _toast("至少选中一行");
                return;
            }
            var idstr=ids.join(",");
            var data={ids:idstr,visible:visible}
            $.post("#(ctx)/admin/user/setVisible",data,function(data){
            	_toast(data.data);
            	if(data.code==0){
            		reloadGrid();
            	}
            },'json');
		}
    </script>
</body> 
</html>